# coding=utf-8
from flask import render_template, request, redirect
from flask import abort,jsonify,url_for,render_template, request, redirect
from flask_cors import CORS, cross_origin
import json
import redis
from flask import Flask
import datetime
from flask_cors import CORS
app = Flask(__name__)
CORS(app)  # 跨域
r = redis.Redis(host='127.0.0.1', port=6379, db=0)

@app.route('/')
def hello_world():
    return '你好!'

@app.route('/voltage')
def get_voltage():
    id = request.args.get('id', '')
    if id:
        json_data = r.get(id)
        if json_data:
            return jsonify(json.loads(json_data))
        return 'no data!'
    return 'no id!'
if __name__ == '__main__':
    app.run(host='127.0.0.1', port=int("5000"))



